package com.atguigu.spzx.service.pay.controller;

import com.atguigu.spzx.model.common.Result;
import com.atguigu.spzx.service.pay.service.PayService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * title:
 * author: zgl
 * date: 2024/1/21
 * description：
 */
@RestController
@RequestMapping("/api/order/alipay")
@Tag(name = "支付模块")
@Slf4j
public class PayController {
    @Resource
    private PayService payService;

    @Operation(summary = "支付宝下单接口")
    @GetMapping("/submitAlipay/{orderNo}")
    public Result submitAlipay(@PathVariable String orderNo) {
        String formData = payService.submitAlipay(orderNo);
        return Result.ok(formData);
    }

    @Operation(summary = "支付宝异步回调")
    @PostMapping("/callback/notify")
    public String payNotify(@RequestParam Map<String, String> params) {
        return payService.payNotify(params);
    }
}
